package com.hyperfix.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hyperfix.models.user.pojos.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author JiangChunYu
 * 2024/4/5
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("select exists (select 1 from user where username = #{username})")
    boolean isUsernameExist(@Param("username") String username);

    @Select("select email from user_info where user_id = (select id from user where username = #{username})")
    String selectUserEmail(@Param("username") String username);

    @Update("update user set password = #{password} where username = #{username}")
    boolean resetPassword(@Param("username") String username, @Param("password") String password);
}
